/*
 * Third.cpp
 *  The third C++ program for CSIS 328
 *  We will use this to explore more C++ types,
 *  arrays, loops, and try out the debugger.
 *  Created on: 2010-03-17
 *      Author: Anthony Varghese
 *
 *  Warning: This program has bugs!
 */

#include <string>
#include <iostream>
using namespace std;

int main() {
	/*
	 * Ask the user for two numbers and swap them if necessary
	 */
	cout << "Enter a number: ";
	int start = 0;
	cin >> start;
	cout << "  Thanks, you entered: " << start << endl;

	cout << "Enter a second number: ";
	int end = 0;
	cin >> end;
	cout << "  Thanks, for the second number you entered: " << end
		 << endl;

	if (start > end){
		cout << "  Since the first number is greater than the second,"
		        "  I will swap them!" << endl;
		int temp = start;
		start = end;
		end   = temp;
	}
	cout << "   The two numbers are " << start << " and " << end << endl;


	/*
	 * Ask the user for a third number to set up an array of
	 * values between the first two numbers.
	 */

	cout << "  I will now set up an array of numbers evenly spaced between" << endl
		 << "    these two numbers. " << endl
		 << "  Please enter a positive number: ";
	int arraysize = 0;
	cin >> arraysize;

	float numbers[ arraysize ];
	float increment = (end-start)/arraysize;

	int index = 0;
	while (index <= arraysize){
		numbers[ index ] = start + index * increment;
	}

	for (int i=0; i<arraysize; i++){
		cout << "    " << numbers[ i ];
	}
	cout << "Done!";
	return 0;
}

